package com.chen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.entity.RoleMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author chenchao
 * @date 2022/7/23 8:58
 */

@Mapper
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {

    /**
     * 选择前删除再选择
     * @param roleId
     * @return
     */
    @Delete("delete from role_menu where role_id=#{roleId}")
    int deleteByRoleId(@Param("roleId") Integer roleId);


    /**
     * 查询当前的角色拥有那些菜单
     *
     * @param roleId
     * @return
     */
    @Select("select menu_id from role_menu where role_id=#{roleId}")
    List<Integer> selectByRoleId(@Param("roleId") Integer roleId);
}
